package mmc.util;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class Utils {
	public static FloatBuffer buf4f;
	
	static {
		buf4f = ByteBuffer.allocateDirect(Float.SIZE*4).order(ByteOrder.nativeOrder()).asFloatBuffer();
	}
	
	public static final FloatBuffer wrap4f(float ... floats){
		if(floats.length!=4){
			throw new RuntimeException("expected length 4!");
		}
		
		buf4f.put(floats);
		buf4f.flip();
		
		return buf4f;
	}
	
	public static final FloatBuffer wrap3f(float ... floats){
		if(floats.length!=3){
			throw new RuntimeException("expected length 4!");
		}
		
		buf4f.clear();
		buf4f.put(floats);
		buf4f.put(0);
		buf4f.flip();
		
		return buf4f;
	}
}
